package com.apress.prospring5.ch6;

import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.object.BatchSqlUpdate;

import javax.sql.DataSource;
import java.sql.Types;

public class InsertSingerAlbum extends BatchSqlUpdate {

    private static final String SQL_INSERT_STRING =
            "insert into ALBUM (singer_id,title,release_date) values(:singer_id,:title,:release_date)";

    private static final int BATCH_SIZE = 10;

    public InsertSingerAlbum(DataSource dataSource) {
        super(dataSource,SQL_INSERT_STRING);

        declareParameter(new SqlParameter("singer_id", Types.INTEGER));
        declareParameter(new SqlParameter("title",Types.VARCHAR));
        declareParameter(new SqlParameter("release_date",Types.DATE));
        setBatchSize(BATCH_SIZE);
    }
}
